/**
 */
package fUML.Semantics.Activities.CompleteStructuredActivities.impl;

import fUML.Semantics.Activities.CompleteStructuredActivities.ClauseActivation;
import fUML.Semantics.Activities.CompleteStructuredActivities.CompleteStructuredActivitiesPackage;
import fUML.Semantics.Activities.CompleteStructuredActivities.ConditionalNodeActivation;

import fUML.Semantics.Classes.Kernel.BooleanValue;

import fUML.Syntax.Activities.CompleteStructuredActivities.Clause;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Clause Activation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fUML.Semantics.Activities.CompleteStructuredActivities.impl.ClauseActivationImpl#getClause <em>Clause</em>}</li>
 *   <li>{@link fUML.Semantics.Activities.CompleteStructuredActivities.impl.ClauseActivationImpl#getConditionalNodeActivation <em>Conditional Node Activation</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ClauseActivationImpl extends EObjectImpl implements ClauseActivation {
	/**
	 * The cached value of the '{@link #getClause() <em>Clause</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClause()
	 * @generated
	 * @ordered
	 */
	protected Clause clause;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ClauseActivationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CompleteStructuredActivitiesPackage.Literals.CLAUSE_ACTIVATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Clause getClause() {
		if (clause != null && clause.eIsProxy()) {
			InternalEObject oldClause = (InternalEObject)clause;
			clause = (Clause)eResolveProxy(oldClause);
			if (clause != oldClause) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CLAUSE, oldClause, clause));
			}
		}
		return clause;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Clause basicGetClause() {
		return clause;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setClause(Clause newClause) {
		Clause oldClause = clause;
		clause = newClause;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CLAUSE, oldClause, clause));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ConditionalNodeActivation getConditionalNodeActivation() {
		if (eContainerFeatureID() != CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION) return null;
		return (ConditionalNodeActivation)eContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetConditionalNodeActivation(ConditionalNodeActivation newConditionalNodeActivation, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newConditionalNodeActivation, CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConditionalNodeActivation(ConditionalNodeActivation newConditionalNodeActivation) {
		if (newConditionalNodeActivation != eInternalContainer() || (eContainerFeatureID() != CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION && newConditionalNodeActivation != null)) {
			if (EcoreUtil.isAncestor(this, newConditionalNodeActivation))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newConditionalNodeActivation != null)
				msgs = ((InternalEObject)newConditionalNodeActivation).eInverseAdd(this, CompleteStructuredActivitiesPackage.CONDITIONAL_NODE_ACTIVATION__CLAUSE_ACTIVATIONS, ConditionalNodeActivation.class, msgs);
			msgs = basicSetConditionalNodeActivation(newConditionalNodeActivation, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION, newConditionalNodeActivation, newConditionalNodeActivation));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void receiveControl() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isReady() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void runTest() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void selectBody() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BooleanValue getDecision() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ClauseActivation> getPredecessors() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ClauseActivation> getSuccessors() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetConditionalNodeActivation((ConditionalNodeActivation)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION:
				return basicSetConditionalNodeActivation(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
		switch (eContainerFeatureID()) {
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION:
				return eInternalContainer().eInverseRemove(this, CompleteStructuredActivitiesPackage.CONDITIONAL_NODE_ACTIVATION__CLAUSE_ACTIVATIONS, ConditionalNodeActivation.class, msgs);
		}
		return super.eBasicRemoveFromContainerFeature(msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CLAUSE:
				if (resolve) return getClause();
				return basicGetClause();
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION:
				return getConditionalNodeActivation();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CLAUSE:
				setClause((Clause)newValue);
				return;
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION:
				setConditionalNodeActivation((ConditionalNodeActivation)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CLAUSE:
				setClause((Clause)null);
				return;
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION:
				setConditionalNodeActivation((ConditionalNodeActivation)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CLAUSE:
				return clause != null;
			case CompleteStructuredActivitiesPackage.CLAUSE_ACTIVATION__CONDITIONAL_NODE_ACTIVATION:
				return getConditionalNodeActivation() != null;
		}
		return super.eIsSet(featureID);
	}

} //ClauseActivationImpl
